<%-- 
    Document   : TerimaBarang
    Created on : Dec 8, 2013, 1:13:28 PM
    Author     : SONY
--%>

<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Lihat Stock Barang</title>
    </head>
    <body><%String a="";
                   
                if("cabangA".equals(session.getAttribute("area"))){
                    a= "CABANG A";
                    session.setAttribute("cabang", "cabangA");
                }
                if("cabangB".equals(session.getAttribute("area"))){
                    a= "CABANG B";
                        session.setAttribute("cabang", "cabangB");
                }if("cabangC".equals(session.getAttribute("area"))){
                    a= "CABANG C";
                        session.setAttribute("cabang", "cabangc");
                } %>
        <form method="post" >
            <h1 align="center" style="color:#00CCFF"> Halaman Manajer </h1>
            <h2 align="center" style="color:black"> Lihat Tabel Stock Barang </h2>
            <p><%=a%> </p>
           
            
            <p></p>

            <% 
                try {

                    Connection con = koneksi.CekKoneksi.open();
                    String kode = request.getParameter("LokasiCabang");
                    Statement stat = con.createStatement();
                    ResultSet rs = null;
                    String in1 = null;
                    in1= "select * from "+session.getAttribute("area");
                   
                    rs = stat.executeQuery(in1);


            %>
            <table border="1">
                <tr>
                    <td><div align="center"><strong>SLNO</strong></div></td>
                    <td>Kode Barang</td>
                    <td>Nama Barang</td>
                    <td>Harga Barang</td>
                    <td>Jumlah</td>
                    <td>Tambah Stock </td>
                </tr>
                <%int icount = 0;

                    while (rs.next()) {
                        String kodeB = rs.getString("KODE_BARANG");
                       
                %>


                <TR>
                    <td><div align="center"><%=++icount%></div></td>
                    <TD><%=rs.getString("KODE_BARANG")%></TD>
                    <TD><%=rs.getString("NAMA_BARANG")%></TD>
                    <TD><%=rs.getString("HARGA_BARANG")%></TD>
                    <TD><%=rs.getString("JUMLAH")%></TD>
                    <td><div align="center"><a href="TerimaBarang2.jsp?kodeB=<%=kodeB%>">Tambah</a></div></td>
                </TR>
                <% }
                %>
            </table>
            <%
                    rs.close();
                } catch (Exception ex) {
                    out.println("Can't connect to database.");
                }
            %>
        </form>
    </body>
</html>
